<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<div align="center">
	<html:form action="/articleListe" method="post" onsubmit="return validateArticleForm(this);">
		<table  style="text-align: right">
			<tr>
				<td height="200" colspan="2">
					<b>Formulaire article</b>
				</td>
			</tr>
			<c:choose>
			  <c:when test="${retour == 1}">
		   			<tr>
					<td>
						Enseigne :
					</td>
					<td>
						<select name="enseigneId" id="enseigneId">
							<c:forEach var="enseigne" items="${listeEnseigne}">
								<option value='<c:out value="${enseigne.id}"/>'> <c:out value="${enseigne.libelle}"/> </option> 
							</c:forEach>
						</select>
					</td>
					<td>
						&nbsp;
					</td>
				</tr>
		    	<tr>
					<td>
						Reference Article :
					</td>
					<td>
						<input type="text" readonly="readonly" name="referenceArticle" size="5" maxlength="5" value="<c:out value="${article.referenceArticle}"/>"/>
					</td>
					<td>
						<a href="<%= request.getContextPath() %>/articleForm.do?generer=1"> Generer Reference </a>
					</td>
				</tr>
				<tr>
					<td>
						Description Courte :
					</td>
					<td>
						<input type="text" name="descriptionCourteArticle" size="16" maxlength="16" value="<c:out value="${article.descriptionCourteArticle}"/>"/>
					</td>
					<td>
						&nbsp;
					</td>
				</tr>
				<tr>
					<td>
						Modele :
					</td>
					<td>
						<input type="text" name="modeleArticle" size="16" maxlength="16" value="<c:out value="${article.modeleArticle}"/>"/>
					</td>
					<td>
						&nbsp;
					</td>
				</tr>
				<tr>
					<td>
						Quantite :
					</td>
					<td>
						<input type="text" name="quantiteStockArticle" size="16" maxlength="16" value="<c:out value="${article.quantiteStockArticle}"/>"/>
					</td>
					<td>
						&nbsp;
					</td>
				</tr>
				<tr>
					<td>
						Description Longue :
					</td>
					<td>
						<textarea rows="5" cols="10" name="descriptionLongueArticle"><c:out value="${article.descriptionLongueArticle}"/></textarea>
					</td>
					<td>
						&nbsp;
					</td>
				</tr>
				<tr>
					<td>
						Prix :
					</td>
					<td>
						<input type="text" name="prixArticle" size="16" maxlength="16" value="<c:out value="${article.prixArticle}"/>"/>
					</td>
					<td>
						&nbsp;
					</td>
				</tr>
				<tr>
					<td>
						Image :
					</td>
					<td>
						<input type="text" name="imageArticle" size="16" maxlength="16" value="<c:out value="${article.imageArticle}"/>"/>
					</td>
					<td>
						&nbsp;
					</td>
				</tr>
				<tr>
					<td>
						&nbsp;
					</td>
					<td>
						<input type="text" name="id" size="5" maxlength="5" value="<c:out value="${article.referenceArticle}"/>"/>
					</td>
				</tr>
			  </c:when>

			  <c:when test="${retour == 0}">
			  	<tr>
					<td>
						Enseigne :
					</td>
					<td>
						<select name="enseigneId" id="enseigneId">
							<c:forEach var="enseigne" items="${listeEnseigne}">
								<option value='<c:out value="${enseigne.id}"/>'> <c:out value="${enseigne.libelle}"/> </option> 
							</c:forEach>
						</select>
					</td>
					<td>
						&nbsp;
					</td>
				</tr>
		    	<tr>
					<td>
						Reference Article :
					</td>
					<td>
						<input type="text" readonly="readonly" name="referenceArticle" size="10" maxlength="10" value="<c:out value="${articleId}"/>"/>
					</td>
					<td>
						<a href="<%= request.getContextPath() %>/articleForm.do?generer=1"> Generer Reference </a>
					</td>
				</tr>
				<tr>
					<td>
						Description Courte :
					</td>
					<td>
						<input type="text" name="descriptionCourteArticle" size="16" maxlength="16" />
					</td>
					<td>
						&nbsp;
					</td>
				</tr>
				<tr>
					<td>
						Modele :
					</td>
					<td>
						<input type="text" name="modeleArticle" size="16" maxlength="16" />
					</td>
					<td>
						&nbsp;
					</td>
				</tr>
				<tr>
					<td>
						Quantite :
					</td>
					<td>
						<input type="text" name="quantiteStockArticle" size="16" maxlength="16" />
					</td>
					<td>
						&nbsp;
					</td>
				</tr>
				<tr>
					<td>
						Description Longue :
					</td>
					<td>
						<textarea rows="5" cols="10" name="descriptionLongueArticle"></textarea>
					</td>
					<td>
						&nbsp;
					</td>
				</tr>
				<tr>
					<td>
						Prix :
					</td>
					<td>
						<input type="text" name="prixArticle" size="16" maxlength="16" />
					</td>
					<td>
						&nbsp;
					</td>
				</tr>
				<tr>
					<td>
						Image :
					</td>
					<td>
						<input type="text" name="imageArticle" size="16" maxlength="16" />
					</td>
					<td>
						&nbsp;
					</td>
				</tr>
				<tr>
					<td>
						&nbsp;
					</td>
					<td>
						<input type="hidden" name="id" size="3" maxlength="3" value="0"/>
					</td>
				</tr>
			  </c:when>
			</c:choose>
			
			<tr style="text-align : center">
				<td colspan="2" height="100">
					<input type="submit" value="Valider" />
				</td>
			</tr>
		</table>
		<html:javascript formName="ArticleForm" />
	</html:form>
</div>
